﻿using AppService.IService.Basic_information;
using AppService.IService.Vehicle_tracks;
using Domain.Entity.Basic_information;
using Domain.Entity.System_operation;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.Vehicle_tracks
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TracksController : ControllerBase
    {

        public ITracksService tracksService { get; set; }

        /// <summary>
        /// 查询运单
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet("{currentPage},{pageSize}")]
        public IActionResult GetMeters(int currentPage, int pageSize, string? name)
        {
            List<Wb_meter> meters = tracksService.GetMeters(currentPage, pageSize, name);
            return Ok(meters);
        }

        /// <summary>
        /// 查询总数
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetCount(string? name)
        {
            int count = tracksService.GetCount(name);
            return Ok(count);
        }

        /// <summary>
        /// 根据id查询司机
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public IActionResult GetDriver(int id)
        {
            Drivers_ment drivers_Ment = tracksService.GetDrivers(id);
            return Ok(drivers_Ment);
        }

        /// <summary>
        /// 根据车辆查询车辆
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public IActionResult GetVehicles(int id)
        {
            Vehicles_ment vehicles_= tracksService.GetVehicles(id);
            return Ok(vehicles_);
        }

        /// <summary>
        /// 根据运单id查询信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public IActionResult GetWb(int id)
        {
            Wb_meter wb_Meter = tracksService.GetMeter(id);
            return Ok(wb_Meter);
        }

    }
}
